﻿using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FreeRedis;

namespace LeafCore.Components.FreeRedis
{
    public static class FreeRedisExtensions
    {
        public static IServiceCollection AddFreeRedis(this IServiceCollection services, string connectionString)
        {
            if (string.IsNullOrEmpty(connectionString))
            {
                throw new ArgumentNullException(message: "Redis连接字符串为空", null);
            }

            var redisClient = new RedisClient(connectionString);

            services.AddSingleton(redisClient);

            return services;
        }
    }
}
